home *** CD-ROM | disk | FTP | other *** search
/ Aminet 9 / Aminet 9 (1995)(GTI - Schatztruhe)[!][Dec 1995].iso / Aminet / game / think / IntuiMines.lha / mine.c < prev    next >
C/C++ Source or Header  |  1992-02-14  |  16KB  |  752 lines

  1. /* IntuiMines ©1992 Jørgen K.    */
  2. /* This is v. 1.0                 */
  3.  
  4. #include <stdio.h>
  5. #include <intuition/intuition.h>
  6. #include <libraries/dos.h>
  7. #include <math.h>
  8. #include <limits.h>
  9. #include <proto/all.h>
  10. #include "images.h"
  11.  
  12. #define HORIZ 30
  13. #define VERT 15
  14. #define TOTAL ((HORIZ+2)*(VERT+2))
  15.  
  16. /* Images: */
  17. #define BLANK 40
  18. #define FLAG 42
  19. #define QMARK 43
  20.  
  21. /* Contents: */
  22. #define NONE 44        /* no content, else a number or BOMBHERE */
  23. #define BOMBHERE 45    /* ! */
  24. #define BLOCKED 46    /* No content in the shadow-border of the matrix */
  25.  
  26.  
  27. struct fieldstruct
  28.     {
  29.         char content;
  30.         char image;
  31.         char beenhere;
  32.         char up;        /* Up or down? */
  33.         int corrindex;    /* The corresponding index to the gadgets */
  34.         int myindex;    /* It's own index */
  35.     };
  36.  
  37. struct fieldstruct thematrix[TOTAL];
  38.  
  39. struct IntuitionBase *IntuitionBase = NULL;
  40. struct IntuiMessage *AMessage = NULL;
  41. struct NewWindow MyNewWindow =
  42.     {
  43.         2,
  44.         10,
  45.         632,
  46.         242,                                /* Placement & size    */
  47.         0,1,                                /* Pens            */
  48.         CLOSEWINDOW|MOUSEBUTTONS|GADGETUP|
  49.         INTUITICKS|REQCLEAR,                /* IDCMPFlags    */
  50.         WINDOWDEPTH|WINDOWCLOSE|WINDOWDRAG|
  51.             SMART_REFRESH|RMBTRAP|ACTIVATE,    /* Flags    */
  52.         NULL,
  53.         NULL,
  54.         "IntuiMines v.1.0 ©1992 Jørgen K.\0",
  55.         NULL,
  56.         NULL,
  57.         0,0,0,0,
  58.         WBENCHSCREEN
  59.     };
  60.  
  61. struct Window *TheWindow = NULL;
  62.  
  63. struct Gadget gadgets[450];
  64.  
  65. struct Gadget smile =
  66.     {
  67.         gadgets,        /* Link to the others */
  68.         310,10,
  69.         21,
  70.         15,
  71.         GADGIMAGE|GADGHIMAGE,
  72.         GADGIMMEDIATE|RELVERIFY,
  73.         BOOLGADGET,
  74.         (APTR) &start1Image,
  75.         (APTR) &start2Image,
  76.         NULL,
  77.         0,
  78.         NULL,
  79.         666,
  80.         NULL
  81.     };
  82.  
  83. char bombstext[3] = "99";
  84. char bleft[] = "Bombs left:";
  85. char tgone[] = "Time:";
  86. char hitext[] = "Hi:";
  87. char name[7] = "Tonje";
  88. char hitime[4] = "999";
  89. int hiscore = 999;
  90. char time[] = "000";
  91.  
  92.  
  93. struct IntuiText timestruct =
  94.     {
  95.         3,0,        /* colors */
  96.         JAM2,
  97.         0,0,        /* le & te */
  98.         NULL,
  99.         time,
  100.         NULL
  101.     };
  102. struct IntuiText histruct =
  103.     {
  104.         3,0,        /* colors */
  105.         JAM2,
  106.         0,0,        /* le & te */
  107.         NULL,
  108.         hitext,
  109.         NULL
  110.     };
  111. struct IntuiText namestruct =
  112.     {
  113.         3,0,        /* colors */
  114.         JAM2,
  115.         0,0,        /* le & te */
  116.         NULL,
  117.         name,
  118.         NULL
  119.     };
  120. struct IntuiText hitimestruct =
  121.     {
  122.         3,0,        /* colors */
  123.         JAM2,
  124.         0,0,        /* le & te */
  125.         NULL,
  126.         hitime,
  127.         NULL
  128.     };
  129. struct IntuiText bombstextstruct =
  130.     {
  131.         3,0,        /* colors */
  132.         JAM2,
  133.         0,0,        /* le & te */
  134.         NULL,
  135.         bombstext,
  136.         NULL
  137.     };
  138. struct IntuiText bleftstruct =
  139.     {
  140.         3,0,        /* colors */
  141.         JAM2,
  142.         0,0,        /* le & te */
  143.         NULL,
  144.         bleft,
  145.         NULL
  146.     };
  147. struct IntuiText timegstruct =
  148.     {
  149.         3,0,        /* colors */
  150.         JAM2,
  151.         0,0,        /* le & te */
  152.         NULL,
  153.         tgone,
  154.         NULL
  155.     };
  156.  
  157. int bombsleft,opened;    /* The flagcounter and the counter for how many */
  158.                         /* opened gadgets there are.                    */
  159. int count;                /* A timecounter - until an interrupt routine is*/
  160.                         /* added. */
  161. UBYTE namebuffer[8];    /* Buffer for the stringgadget.                    */
  162.  
  163. /* ********************************************************************** */
  164.  
  165. /* Here come the protos: */
  166. void dohi(void);
  167. void create_matrix(void);
  168. int gimmearand(void);
  169. void openblanks (int center);
  170. void opencell (int index);
  171. char between(int index);
  172. void revealall(void);
  173. void clearall(void);
  174. void printtext(void);
  175. void printtime(void);
  176.  
  177. /* ********************************************************************** */
  178.  
  179. void main(void)
  180. {
  181.     int done = FALSE,index,matindex;
  182.     ULONG class;
  183.     USHORT code;
  184.     SHORT mousex,mousey;
  185.     APTR iadr;
  186.     char thecontent;
  187.     struct RastPort *rastport;
  188.     int mytime=10;        /* A simple timer */
  189.     char stop = FALSE;    /* stop counting */
  190.  
  191.     create_matrix();
  192.  
  193.     /* Open a window: */
  194.     IntuitionBase=(struct IntuitionBase *) OpenLibrary("intuition.library",1);
  195.  
  196.     if(IntuitionBase == NULL) {printf("no lib\n");exit(0);}
  197.  
  198.     TheWindow = OpenWindow(&MyNewWindow);
  199.     if(TheWindow == NULL) {printf("no window\n");exit(0);}
  200.  
  201.     AddGList(TheWindow,&smile,0,-1,NULL);
  202.     RefreshGList(&smile,TheWindow,NULL,-1);
  203.     /* Draw the "borders": */
  204.     rastport=TheWindow->RPort;
  205.     DrawImage(rastport,&onblankImage,550,10);
  206.     DrawImage(rastport,&timeframeImage,400,10);
  207.     printtext();
  208.     /* Print the texts: */
  209.     PrintIText(rastport,&bleftstruct,460,13);
  210.     PrintIText(rastport,&timegstruct,355,13);
  211.     PrintIText(rastport,&histruct,30,13);
  212.     PrintIText(rastport,&namestruct,100,13);
  213.     PrintIText(rastport,&hitimestruct,60,13);
  214.     printtime();
  215.  
  216.     /* The loop: */
  217.     while (!done)
  218.     {
  219.         Wait(1L<<TheWindow->UserPort->mp_SigBit);
  220.         while(AMessage=(struct IntuiMessage *) GetMsg(TheWindow->UserPort))
  221.         {
  222.             class = AMessage->Class;
  223.             code = AMessage->Code;
  224.             mousex = AMessage->MouseX;
  225.             mousey = AMessage->MouseY;
  226.             iadr = AMessage->IAddress;
  227.  
  228.             ReplyMsg((struct Message *)AMessage);
  229.             if(class == CLOSEWINDOW)
  230.             {
  231.                 /* Do NOT close the window here! */
  232.                 done = TRUE;
  233.             }
  234.  
  235.             if((class == INTUITICKS)&&(!stop))
  236.             {
  237.                 if(!(--mytime))
  238.                 {
  239.                     mytime=10;
  240.                     if(count<999)
  241.                     {
  242.                         count++;
  243.                         printtime();
  244.                     }
  245.                 }
  246.             }
  247.  
  248.             if((class == MOUSEBUTTONS)&&(code == MENUUP)&&(mousey>30)&&
  249.                 (mousey<240)&&(mousex>0)&&(mousex<630))
  250.             {
  251.                 /* We gotta do some calculus... */
  252.                 mousey-=31;
  253.                 index=(mousex/21)+((mousey/14)*30);
  254.  
  255.                 if((((struct fieldstruct*)gadgets[index].UserData)->image
  256.                     == BLANK)&&(bombsleft))
  257.                 {
  258.                     gadgets[index].GadgetRender=(APTR) &flagImage;
  259.                     ((struct fieldstruct*)gadgets[index].UserData)->image
  260.                         = FLAG;
  261.  
  262.                     bombsleft--;
  263.                     printtext();
  264.                     
  265.                 }
  266.                 else
  267.                 {
  268.                     if(((struct fieldstruct*)gadgets[index].UserData)->image
  269.                         == FLAG)
  270.                     {
  271.                         gadgets[index].GadgetRender=(APTR) &qmarkImage;
  272.                         ((struct fieldstruct*)gadgets[index].UserData)->image
  273.                             = QMARK;
  274.                         bombsleft++;
  275.                         printtext();
  276.                     }
  277.                     else
  278.                     {
  279.                         gadgets[index].GadgetRender=(APTR) &offblankImage;
  280.                         ((struct fieldstruct*)gadgets[index].UserData)->image
  281.                             = BLANK;
  282.                     }
  283.                 }
  284.                 RefreshGList(&gadgets[index],TheWindow,NULL,1);
  285.             }
  286.  
  287.             if(class == GADGETUP)
  288.             {
  289.                 if(((struct Gadget *) iadr)->GadgetID == 666)
  290.                 {
  291.                     /* Restart */
  292.                     clearall();
  293.                     stop = FALSE;
  294.                     RefreshGList(gadgets,TheWindow,NULL,-1);
  295.                     printtext();
  296.                 }
  297.                 else
  298.                 {
  299.                     /* An ordinary gadget */
  300.                     index = ((struct Gadget *) iadr)->GadgetID;
  301.  
  302.                     thecontent=((struct fieldstruct*)gadgets[index].UserData)
  303.                         ->content;
  304.                     matindex=((struct fieldstruct*)gadgets[index].UserData)
  305.                         ->myindex;
  306.  
  307.                     if( ((struct fieldstruct*)gadgets[index].UserData)
  308.                         ->image == FLAG)
  309.                     {
  310.                         /* Update the flagcounter */
  311.                         bombsleft++;
  312.                         ((struct fieldstruct*)gadgets[index].UserData)->image
  313.                             = BLANK;
  314.                         printtext();
  315.                     }
  316.  
  317.                     if(thecontent == BOMBHERE)
  318.                     {
  319.                         /* Game over */
  320.                         stop = TRUE;
  321.                         revealall();
  322.                     }
  323.  
  324.                     if(thecontent == NONE) openblanks(matindex);
  325.                     else
  326.                     {
  327.                         if(!thematrix[matindex].beenhere)
  328.                         {
  329.                             opened--;
  330.                             thematrix[matindex].beenhere=TRUE;
  331.                         }
  332.                     }
  333.  
  334.                     if(!opened)
  335.                     {
  336.                         /* You have won! */
  337.                         stop = TRUE;
  338.                         revealall();
  339.                         if(count <= hiscore)
  340.                         {
  341.                             /* I do believe we've got a hiscore */
  342.                             /* Open the requester: */
  343.                             dohi();
  344.                             /* Go until we receive a REQCLEAR... */
  345.                             hiscore=count;
  346.                         }
  347.                     }
  348.                 }
  349.             }/* gadgetup */
  350.  
  351.             if(class == REQCLEAR)
  352.             {
  353.                 /* Name typed in (don't bother with other reqs... erm) */
  354.                 sprintf(name,"%s",namebuffer);
  355.                 PrintIText(rastport,&namestruct,100,13);
  356.                 if(hiscore<10)
  357.                     sprintf(hitime,"00%d\0",hiscore);
  358.                 else
  359.                     if(hiscore<100)
  360.                         sprintf(hitime,"0%d\0",hiscore);
  361.                     else
  362.                         sprintf(hitime,"%d\0",hiscore);
  363.  
  364.                 PrintIText(rastport,&hitimestruct,60,13);
  365.             }
  366.  
  367.         }/* while */
  368.     }/* while !done */
  369.     CloseWindow(TheWindow);
  370.     CloseLibrary((struct Library *)IntuitionBase);
  371. }
  372.  
  373. /* ********************************************************************** */
  374.  
  375. void dohi(void)
  376. {
  377.     /* Make'em static because otherwise they would be on the stack; */
  378.     /* pointer problems!                                             */
  379.  
  380.     static char hiscoretxt[] = "Hiscore! Please type your name:";
  381.  
  382.     static struct IntuiText thetext =
  383.         {
  384.             3,1,        /* colors */
  385.             JAM2,
  386.             5,3,        /* le & te */
  387.             NULL,
  388.             hiscoretxt,
  389.             NULL
  390.         };
  391.  
  392.     static struct StringInfo string =
  393.         {
  394.             namebuffer,
  395.             NULL,
  396.             0,
  397.             8,
  398.             0,
  399.             0,0,0,0,0,0,0,NULL
  400.         };
  401.  
  402.     static SHORT vector1[] =
  403.         {
  404.             0,0,
  405.             0,39,
  406.             259,39,
  407.             259,0,
  408.             0,0
  409.         };
  410.  
  411.     static SHORT vector2[] =
  412.         {
  413.             0,0,
  414.             0,12,
  415.             72,12,
  416.             72,0,
  417.             0,0
  418.         };
  419.  
  420.     static struct Border border2=
  421.         {
  422.             79,24,
  423.             3,3,JAM1,
  424.             5,
  425.             vector2,
  426.             NULL
  427.         };
  428.  
  429.     static struct Border border =
  430.         {
  431.             0,0,
  432.             3,3,JAM1,
  433.             5,
  434.             vector1,
  435.             &border2
  436.         };
  437.  
  438.     static struct Gadget txtinput =
  439.         {
  440.             NULL,
  441.             80,25,
  442.             70,10,
  443.             GADGHCOMP|SELECTED,
  444.             ENDGADGET|STRINGCENTER,
  445.             STRGADGET|REQGADGET,
  446.             NULL,NULL,
  447.             NULL,
  448.             0L,
  449.             (APTR) &string,
  450.             777,
  451.             NULL
  452.         };
  453.  
  454.     static struct Requester hinamereq =
  455.         {
  456.             NULL,
  457.             50,50,260,40,
  458.             0,0,
  459.             &txtinput,
  460.             &border,
  461.             &thetext,
  462.             NULL,
  463.             0,
  464.             NULL,
  465.             {NULL},
  466.             NULL,
  467.             NULL,
  468.             {NULL},
  469.         };
  470.  
  471.     sprintf(namebuffer,"%s",name);
  472.     Request(&hinamereq,TheWindow);
  473. }
  474.  
  475. /* ********************************************************************** */
  476.  
  477. void printtext(void)
  478. {
  479.     /* Prints # bombs left */
  480.  
  481.     struct RastPort *rastport;
  482.  
  483.     rastport = TheWindow->RPort;
  484.  
  485.     bombstext[0]=(bombsleft/10)+'0';
  486.     bombstext[1]=bombsleft-((bombsleft/10)*10)+'0';
  487.     PrintIText(rastport,&bombstextstruct,553,13);
  488. }
  489.  
  490. /* ********************************************************************** */
  491.  
  492. void printtime(void)
  493. {
  494.     time[0]=(count/100)+'0';
  495.     time[1]=(count-((count/100)*100))/10+'0';
  496.     time[2]=count-((count/100)*100);
  497.     time[2]=time[2]-((time[2]/10)*10)+'0';
  498.  
  499.     PrintIText(TheWindow->RPort,×truct,403,13);
  500. }
  501.  
  502. /* ********************************************************************* */
  503.  
  504. void revealall(void)
  505. {
  506.     int x;
  507.     USHORT flags;
  508.  
  509.     for(x=0;x<450;x++)
  510.     {
  511.         if((((struct fieldstruct*)gadgets[x].UserData)->image == FLAG) && 
  512.             (((struct fieldstruct*)gadgets[x].UserData)->content != BOMBHERE))
  513.             gadgets[x].SelectRender= (APTR) &bombcrossImage;
  514.  
  515.         flags=gadgets[x].Flags;
  516.         gadgets[x].Flags=flags|SELECTED;
  517.         RefreshGList(&gadgets[x],TheWindow,NULL,1);
  518.     }
  519.     /* Why not possible to refresh the whole list in one operation?? */
  520. }
  521.  
  522. /* ********************************************************************** */
  523.  
  524. char between (int index)
  525. {
  526.     if((thematrix[index].content > 0) && (thematrix[index].content < 9))
  527.         return (TRUE);
  528.     else
  529.         return (FALSE);
  530. }
  531.  
  532. /* ********************************************************************* */
  533.  
  534. void opencell(int index)
  535. {
  536.     USHORT flags;
  537.  
  538.     if(!thematrix[index].beenhere)
  539.     {
  540.         opened--;    /* ! */
  541.         thematrix[index].beenhere = TRUE;
  542.  
  543.         if(thematrix[index].image == FLAG)
  544.         {
  545.             bombsleft++;
  546.             printtext();
  547.         }
  548.     }
  549.  
  550.     flags=gadgets[thematrix[index].corrindex].Flags;
  551.     gadgets[thematrix[index].corrindex].Flags=flags|SELECTED;
  552.     RefreshGList(&gadgets[thematrix[index].corrindex],TheWindow,NULL,1);
  553.     thematrix[index].up=FALSE;
  554. }
  555.  
  556. /* ******************************************************************** */
  557.  
  558. void openblanks(int center)
  559. {
  560.     if((center > TOTAL) || (center < 0)) return;
  561.  
  562.     if(thematrix[center].content == BOMBHERE) return;
  563.  
  564.     /* Take care not to crash: */
  565.     if(thematrix[center].corrindex != -1)
  566.     {
  567.         /* Make the gadget selected... */
  568.         opencell(center);
  569.     }
  570.  
  571.     /* A number */
  572.     if((thematrix[center].content>0) && (thematrix[center].content<9)) return;
  573.  
  574.     /* We have a blank; check for special case: */
  575.     if( between(center-1) && between(center+32) &&
  576.         between(center+31))
  577.         opencell(center+31);
  578.  
  579.     if( between(center-1) && between(center-32) &&
  580.         between(center-33))
  581.         opencell(center-33);
  582.  
  583.     if( between(center+1) && between(center-32) &&
  584.         between(center-31))
  585.         opencell(center-31);
  586.  
  587.     if( between(center+1) && between(center+32) &&
  588.         between(center+33))
  589.         opencell(center+33);
  590.  
  591.  
  592.     /* Blank */
  593.     if((thematrix[center-32].up) && (thematrix[center-32].content != BLOCKED))
  594.         openblanks(center-32);
  595.     if((thematrix[center-1].up) && (thematrix[center-1].content != BLOCKED))
  596.         openblanks(center-1);
  597.     if((thematrix[center+1].up) && (thematrix[center+1].content != BLOCKED))
  598.         openblanks(center+1);
  599.     if((thematrix[center+32].up) && (thematrix[center+32].content != BLOCKED))
  600.         openblanks(center+32);
  601. }
  602.  
  603. /* ************************************************************************ */
  604.  
  605. int gimmearand(void)
  606. {
  607.     /* Supposed to return a number (an index) */
  608.     
  609.     return((int)(drand48()*TOTAL));
  610. }
  611.  
  612. /* ************************************************************************ */
  613.  
  614. void clearall(void)
  615. {
  616.     int x,y,bombs,center;
  617.  
  618.  
  619.     for(x=0;x<TOTAL;x++)
  620.     {
  621.         thematrix[x].image=BLANK;
  622.         thematrix[x].content=NONE;
  623.         thematrix[x].up=TRUE;
  624.         thematrix[x].beenhere=FALSE;
  625.     }
  626.  
  627.     /* Block the "extra cells" out: */
  628.     for(x=0;x<HORIZ+2;x++)
  629.     {
  630.         thematrix[x].content=BLOCKED;
  631.         thematrix[x+((VERT+1)*32)].content=BLOCKED;
  632.     }
  633.     for(x=0;x<VERT+2;x++)
  634.     {
  635.         thematrix[x*32].content=BLOCKED;
  636.         thematrix[(x*32)+31].content=BLOCKED;
  637.     }
  638.  
  639.     /* Place the bombs: */
  640.     for(x=0;x<99;x++)
  641.     {
  642.         y=gimmearand();
  643.         while(thematrix[y].content==BOMBHERE||
  644.             thematrix[y].content==BLOCKED)
  645.             y=gimmearand();
  646.  
  647.         thematrix[y].content=BOMBHERE;
  648.     }
  649.  
  650.     for(x=0;x<450;x++)
  651.     {
  652.         gadgets[x].Flags=(GADGIMAGE|GADGHIMAGE)&(~SELECTED);
  653.         gadgets[x].GadgetRender=(APTR) &offblankImage;
  654.         if(((struct fieldstruct*)gadgets[x].UserData)->content
  655.             != BOMBHERE)
  656.             gadgets[x].SelectRender=(APTR) &onblankImage;
  657.         else
  658.             gadgets[x].SelectRender=(APTR) &bombImage;
  659.     }
  660.  
  661.     /* Go thru the motions with counting the bombs: */
  662.     for(x=0;x<450;x++)
  663.     {
  664.         center=((struct fieldstruct*)gadgets[x].UserData)->myindex;
  665.         if(thematrix[center].content != BOMBHERE)
  666.         {
  667.             bombs=0;
  668.             if(thematrix[center-33].content==BOMBHERE) bombs++;
  669.             if(thematrix[center-32].content==BOMBHERE) bombs++;
  670.             if(thematrix[center-31].content==BOMBHERE) bombs++;
  671.             if(thematrix[center-1].content==BOMBHERE) bombs++;
  672.             if(thematrix[center+1].content==BOMBHERE) bombs++;
  673.             if(thematrix[center+31].content==BOMBHERE) bombs++;
  674.             if(thematrix[center+32].content==BOMBHERE) bombs++;
  675.             if(thematrix[center+33].content==BOMBHERE) bombs++;
  676.  
  677.             if(bombs) thematrix[center].content=bombs;
  678.  
  679.             switch(bombs)
  680.             {
  681.                 case 1:    gadgets[x].SelectRender=(APTR) &nroneImage;
  682.                         break;
  683.                 case 2:    gadgets[x].SelectRender=(APTR) &nrtwoImage;
  684.                         break;
  685.                 case 3:    gadgets[x].SelectRender=(APTR) &nrthreeImage;
  686.                         break;
  687.                 case 4:    gadgets[x].SelectRender=(APTR) &nrfourImage;
  688.                         break;
  689.                 case 5:    gadgets[x].SelectRender=(APTR) &nrfiveImage;
  690.                         break;
  691.                 case 6:    gadgets[x].SelectRender=(APTR) &nrsixImage;
  692.                         break;
  693.                 case 7:    gadgets[x].SelectRender=(APTR) &nrsevenImage;
  694.                         break;
  695.                 case 8:    gadgets[x].SelectRender=(APTR) &nreightImage;
  696.                         break;
  697.             }/* case */
  698.         }/* if */
  699.     }/* for */
  700.  
  701.     bombsleft = 99;
  702.     opened = 450-99;
  703.     count = 0;
  704. }
  705.  
  706. /* ************************************************************************ */
  707.  
  708. void create_matrix(void)
  709. {
  710.     int x,y,z;
  711.  
  712.     /* Initialize: */
  713.     for(x=0;x<TOTAL;x++)
  714.     {
  715.         thematrix[x].corrindex=-1;
  716.         thematrix[x].myindex=x;
  717.     }
  718.  
  719.     /* Set the corrindex: */
  720.     z=0;
  721.     for(x=33;x<=481;x+=32)
  722.         for(y=0;y<30;y++)
  723.         {
  724.             /* Linking the suckers together: */
  725.             thematrix[y+x].corrindex=z;
  726.             gadgets[z].UserData=(APTR)&thematrix[y+x];
  727.             z++;
  728.         }
  729.  
  730.     clearall();    /* ...and place the bombs */
  731.  
  732.     /* Set up the gadgets: */
  733.     for(x=0;x<450;x++)
  734.     {
  735.         gadgets[x].NextGadget=&gadgets[x+1];
  736.         gadgets[x].LeftEdge=((x-(30*(x/30)))*21)+1;
  737.         gadgets[x].TopEdge=((x/30)*14)+30;
  738.         gadgets[x].Width=21;
  739.         gadgets[x].Height=15;
  740.  
  741.         gadgets[x].Activation=TOGGLESELECT|RELVERIFY;
  742.         gadgets[x].GadgetType=BOOLGADGET;
  743.  
  744.         gadgets[x].GadgetText=NULL;
  745.         gadgets[x].MutualExclude=0;
  746.         gadgets[x].SpecialInfo=0;
  747.         gadgets[x].GadgetID=x;
  748.     }
  749.     gadgets[449].NextGadget=NULL;
  750.  
  751. }/* creatematrix() */
  752.